package demo13;

/**
 * @program: qy158
 * @description:
 * @author: 闫克起2
 * @create: 2022-11-01 09:33
 **/
public class TestDaemon {
    public static void main(String[] args) {
        DaemonDemo t1=new DaemonDemo();
        t1.setDaemon(true);//设置t1为守护线程---当前台线程执行完毕后，守护线程也会结束
        t1.start();


        DaemonDemo t2=new DaemonDemo();
       // t2.setDaemon(true);//设置t1为守护线程---当前台线程执行完毕后，守护线程也会结束
        t2.start();

    }
}
class DaemonDemo extends Thread{

    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName()+"~~~~~~~~~~"+i);
        }
    }
}
